home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / Demos / Donuts3D / donuts.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  20.0 KB  |  545 lines

  1. //-----------------------------------------------------------------------------
  2. // File: Donuts.h
  3. //
  4. // Desc: Header for Donuts3D game
  5. //
  6. // Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef DONUTS_H
  9. #define DONUTS_H
  10.  
  11.  
  12.  
  13.  
  14. //-----------------------------------------------------------------------------
  15. // Defines, and constants
  16. //-----------------------------------------------------------------------------
  17. // This GUID must be unique for every game, and the same for 
  18. // every instance of this app.  // {2014BAAC-F1FD-458e-9091-0F85C8CF6AFE}
  19. // The GUID allows DirectInput to remember input settings
  20. GUID g_guidApp = { 0x2014baac, 0xf1fd, 0x458e, { 0x90, 0x91, 0xf, 0x85, 0xc8, 0xcf, 0x6a, 0xfe } };
  21.  
  22. // Error codes
  23. #define DONUTS3DERR_NODIRECT3D       0x00000001
  24. #define DONUTS3DERR_NOD3DDEVICE      0x00000002
  25. #define DONUTS3DERR_NOTEXTURES       0x00000003
  26. #define DONUTS3DERR_NOGEOMETRY       0x00000004
  27. #define DONUTS3DERR_NO3DRESOURCES    0x00000005
  28. #define DONUTS3DERR_NOINPUT          0x00000006
  29.  
  30. // States the app can be in
  31. enum{ APPSTATE_LOADSPLASH, APPSTATE_DISPLAYSPLASH, APPSTATE_ACTIVE, 
  32.       APPSTATE_BEGINLEVELSCREEN, APPSTATE_DISPLAYLEVELSCREEN };
  33.  
  34. // Game object types
  35. enum{ OBJ_DONUT=0, OBJ_PYRAMID, OBJ_CUBE, OBJ_SPHERE, OBJ_CLOUD, OBJ_SHIP,
  36.       OBJ_BULLET };
  37.  
  38. // Object dimensions and fixed properties
  39. #define DONUT_WIDTH        32
  40. #define DONUT_HEIGHT       32
  41. #define PYRAMID_WIDTH      32
  42. #define PYRAMID_HEIGHT     32
  43. #define SPHERE_WIDTH       16
  44. #define SPHERE_HEIGHT      16
  45. #define CUBE_WIDTH         16
  46. #define CUBE_HEIGHT        16
  47. #define CLOUD_WIDTH        32
  48. #define CLOUD_HEIGHT       32
  49. #define BULLET_WIDTH        3
  50. #define BULLET_HEIGHT       3
  51.  
  52. #define NUM_DONUT_FRAMES   30
  53. #define NUM_PYRAMID_FRAMES 40
  54. #define NUM_SPHERE_FRAMES  40
  55. #define NUM_CUBE_FRAMES    40
  56. #define NUM_BULLET_FRAMES 400
  57.  
  58. #define BULLET_XOFFSET    304
  59. #define BULLET_YOFFSET      0
  60.  
  61. // Defines for the in-game menu
  62. #define MENU_MAIN           1
  63. #define MENU_SOUND          2
  64. #define MENU_VIDEO          3
  65. #define MENU_INPUT          4
  66. #define MENU_VIEWDEVICES    5
  67. #define MENU_CONFIGDEVICES  6
  68. #define MENU_WINDOWED       7
  69. #define MENU_640x480        8
  70. #define MENU_800x600        9
  71. #define MENU_1024x768      10
  72. #define MENU_BACK          11
  73. #define MENU_SOUNDON       12
  74. #define MENU_SOUNDOFF      13
  75. #define MENU_QUIT          14
  76.  
  77.  
  78. TCHAR* g_strShipFiles[] = { _T("Concept Plane 3.x"), _T("Spaceship 2.x"), _T("Shusui.x"),
  79.                              _T("Space Station 7.x"), _T("Spaceship 8.x"), _T("Orbiter.x"),
  80.                              _T("Spaceship 13.x"),    _T("Spaceship 5.x"), _T("Star Sail.x"), 
  81.                              _T("Heli.x"), };
  82. TCHAR* g_strShipNames[] = { _T("Concept Plane"), _T("Green Machine"),  _T("Purple Prowler"),
  83.                              _T("Drone Clone"),   _T("Canyon Fighter"), _T("Roundabout"),
  84.                              _T("Tie-X7"),        _T("Gunner"),         _T("Star Sail"), 
  85.                              _T("Helicopter"), };
  86.  
  87.  
  88.  
  89. //-----------------------------------------------------------------------------
  90. // Name: struct DisplayObject
  91. // Desc: A game object that goes in the display list
  92. //-----------------------------------------------------------------------------
  93. struct DisplayObject
  94. {
  95.     DisplayObject* pNext;          // Link to next object
  96.     DisplayObject* pPrev;          // Link to previous object
  97.     
  98.     DWORD          dwType;            // Type of object
  99.     BOOL           bVisible;          // Whether the object is visible
  100.     D3DXVECTOR3    vPos;              // Position
  101.     D3DXVECTOR3    vVel;              // Velocity
  102.     FLOAT          fSize;
  103.     
  104.     // Constructor
  105.     DisplayObject( DWORD type, D3DVECTOR p, D3DVECTOR v );
  106. };
  107.  
  108.  
  109. //-----------------------------------------------------------------------------
  110. // Derived classes for displayable game objects
  111. //-----------------------------------------------------------------------------
  112. struct C3DSprite : public DisplayObject
  113. {
  114.     DWORD dwFramesPerLine;   // How anim frames are packed in bitmap
  115.     FLOAT frame;             // Current animation frame
  116.     FLOAT fMaxFrame;         // Max animation frame value
  117.     FLOAT delay;             // Frame/second
  118.     
  119.     DWORD dwColor;
  120.  
  121.     DWORD dwTextureOffsetX; // Pixel offsets into the game texture
  122.     DWORD dwTextureOffsetY;
  123.     DWORD dwTextureWidth;   // Width and height in pixels
  124.     DWORD dwTextureHeight; 
  125.     
  126.     C3DSprite( DWORD type, D3DVECTOR p, D3DVECTOR v );
  127. };
  128.  
  129.  
  130. class CDonut : public C3DSprite
  131. {
  132. public:
  133.     CDonut( D3DVECTOR p, D3DVECTOR v );
  134. };
  135.  
  136.  
  137. class CPyramid : public C3DSprite
  138. {
  139. public:
  140.     CPyramid( D3DVECTOR p, D3DVECTOR v );
  141. };
  142.  
  143.  
  144. class CSphere : public C3DSprite
  145. {
  146. public:
  147.     CSphere( D3DVECTOR p, D3DVECTOR v );
  148. };
  149.  
  150.  
  151. class CCube : public C3DSprite
  152. {
  153. public:
  154.     CCube( D3DVECTOR p, D3DVECTOR v );
  155. };
  156.  
  157.  
  158. class CCloud : public C3DSprite
  159. {
  160. public:
  161.     CCloud( D3DVECTOR p, D3DVECTOR v );
  162. };
  163.  
  164.  
  165. class CBullet : public C3DSprite
  166. {
  167. public:
  168.     CBullet( D3DVECTOR p, D3DVECTOR v, DWORD dwType );
  169. };
  170.  
  171.  
  172. class CShip : public DisplayObject
  173. {
  174. public:
  175.     FLOAT fRoll;
  176.  
  177.     FLOAT fAngle;
  178.  
  179.     BOOL  bExploded;
  180.     FLOAT fShowDelay;
  181.  
  182. public:
  183.     CShip( D3DVECTOR p );
  184. };
  185.  
  186.  
  187.  
  188. //-----------------------------------------------------------------------------
  189. // Custom Direct3D vertex types
  190. //-----------------------------------------------------------------------------
  191. struct SCREENVERTEX
  192. {
  193.     D3DXVECTOR4 p;
  194.     DWORD       color;
  195. };
  196.  
  197. struct SPRITEVERTEX
  198. {
  199.     D3DXVECTOR3 p;
  200.     DWORD       color;
  201.     FLOAT       tu, tv;
  202. };
  203.  
  204. struct MODELVERTEX
  205. {
  206.     D3DXVECTOR3 p;
  207.     D3DXVECTOR3 n;
  208.     FLOAT       tu, tv;
  209. };
  210.  
  211. #define D3DFVF_SCREENVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
  212. #define D3DFVF_SPRITEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
  213. #define D3DFVF_MODELVERTEX  (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
  214.  
  215.  
  216. //-----------------------------------------------------------------------------
  217. // App defined structures
  218. //-----------------------------------------------------------------------------
  219.  
  220. // DirectInput action mapper reports events only when buttons/axis change
  221. // so we need to remember the present state of relevant axis/buttons for 
  222. // each DirectInput device.  The CInputDeviceManager will store a 
  223. // pointer for each device that points to this struct
  224. struct InputDeviceState
  225. {
  226.     FLOAT fAxisMoveUD;
  227.     BOOL  bButtonForwardThrust;
  228.     BOOL  bButtonReverseThrust;
  229.  
  230.     FLOAT fAxisRotateLR;
  231.     BOOL  bButtonRotateLeft;
  232.     BOOL  bButtonRotateRight;
  233.  
  234.     BOOL  bButtonFireWeapons;
  235.  
  236.     // Menu input variables
  237.     FLOAT fAxisMenuUD;
  238. };
  239.  
  240. // Struct to store the current input state
  241. struct UserInput
  242. {
  243.     FLOAT fAxisMoveUD;
  244.     FLOAT fAxisRotateLR;
  245.     BOOL  bButtonFireWeapons;
  246.     BOOL  bButtonEnableShield;
  247.  
  248.     // One-shot variables
  249.     BOOL  bDoChangeView;    
  250.  
  251.     // Menu input variables
  252.     BOOL  bDoMenuUp;
  253.     BOOL  bDoMenuDown;
  254.     BOOL  bDoMenuSelect;
  255.     BOOL  bDoMenuQuit;
  256.  
  257. };
  258.  
  259.  
  260. //-----------------------------------------------------------------------------
  261. // Game actions (using DInput semantic mapper). The definitions here are kind
  262. // of the whole point of this sample. The game uses these actions to map
  263. // physical input like, "the user pressed the 'W' key", to a more useable
  264. // constant for the game, like "if( dwInput == INPUT_CHANGEWEAPONS )...".
  265. //-----------------------------------------------------------------------------
  266.  
  267. // Input semantics used by this game
  268. enum INPUT_SEMANTICS
  269. {
  270.     // Gameplay semantics
  271.     INPUT_AXIS_LR=1,     INPUT_AXIS_UD,       
  272.     INPUT_MOUSE_LR,      INPUT_MOUSE_UD,      INPUT_MOUSE_SHIPTYPE,
  273.     INPUT_TURNLEFT,      INPUT_TURNRIGHT,     INPUT_FORWARDTHRUST,
  274.     INPUT_REVERSETHRUST, INPUT_FIREWEAPONS,   INPUT_CHANGESHIPTYPE,
  275.     INPUT_CHANGEVIEW,    INPUT_CHANGEWEAPONS, INPUT_DISPLAYGAMEMENU,
  276.     INPUT_QUITGAME,      INPUT_START,
  277.  
  278.     // Menu semantics
  279.     INPUT_MENU_UD,       INPUT_MENU_WHEEL,
  280.     INPUT_MENU_UP,       INPUT_MENU_DOWN,     
  281.     INPUT_MENU_SELECT,   INPUT_MENU_QUIT,
  282. };
  283.  
  284. // Game actions used by this game.
  285. DIACTION g_rgGameAction[] =
  286. {
  287.     // (C:\Program Files\DirectX\DirectInput\User Maps\*.ini)
  288.     // after changing this, otherwise settings won't reset and will be read 
  289.     // from the out of date ini files 
  290.  
  291.     // Device input (joystick, etc.) that is pre-defined by DInput, according
  292.     // to genre type. The genre for this app is space simulators.
  293.     { INPUT_AXIS_LR,         DIAXIS_SPACESIM_LATERAL,   0, TEXT("Turn"), },
  294.     { INPUT_AXIS_UD,         DIAXIS_SPACESIM_MOVE,      0, TEXT("Move"), },
  295.     { INPUT_FIREWEAPONS,     DIBUTTON_SPACESIM_FIRE,    0, TEXT("Fire weapons"), },
  296.     { INPUT_CHANGEVIEW,      DIBUTTON_SPACESIM_VIEW,    0, TEXT("Change view"), },
  297.     { INPUT_CHANGEWEAPONS,   DIBUTTON_SPACESIM_WEAPONS, 0, TEXT("Change weapons"), },
  298.     { INPUT_CHANGESHIPTYPE,  DIBUTTON_SPACESIM_LOWER,    0, TEXT("Change ship type"), },
  299.     { INPUT_DISPLAYGAMEMENU, DIBUTTON_SPACESIM_DEVICE,    0, TEXT("Display game menu"), },
  300.     { INPUT_START,           DIBUTTON_SPACESIM_MENU,  0, TEXT("Start/pause"), },
  301.  
  302.     // Keyboard input mappings
  303.     { INPUT_TURNLEFT,        DIKEYBOARD_LEFT,    0, TEXT("Turn left"), },
  304.     { INPUT_TURNRIGHT,       DIKEYBOARD_RIGHT,   0, TEXT("Turn right"), },
  305.     { INPUT_FORWARDTHRUST,   DIKEYBOARD_UP,      0, TEXT("Forward thrust"), },
  306.     { INPUT_REVERSETHRUST,   DIKEYBOARD_DOWN,    0, TEXT("Reverse thrust"), },
  307.     { INPUT_FIREWEAPONS,     DIKEYBOARD_SPACE,   0, TEXT("Fire weapons"), },
  308.     { INPUT_CHANGESHIPTYPE,  DIKEYBOARD_A,       0, TEXT("Change ship type"), },
  309.     { INPUT_CHANGEVIEW,      DIKEYBOARD_V,       0, TEXT("Change view"), },
  310.     { INPUT_CHANGEWEAPONS,   DIKEYBOARD_W,       0, TEXT("Change weapons"), },
  311.     { INPUT_DISPLAYGAMEMENU, DIKEYBOARD_F1,      DIA_APPFIXED, TEXT("Display game menu"), },
  312.     { INPUT_START,           DIKEYBOARD_PAUSE,   0, TEXT("Start/pause"), },
  313.     { INPUT_QUITGAME,        DIKEYBOARD_ESCAPE,  DIA_APPFIXED, TEXT("Quit game"), },
  314.  
  315.     // Mouse input mappings
  316.     { INPUT_MOUSE_LR,        DIMOUSE_XAXIS,      0, TEXT("Turn"), },
  317.     { INPUT_MOUSE_UD,        DIMOUSE_YAXIS,      0, TEXT("Move"), },
  318.     { INPUT_MOUSE_SHIPTYPE,  DIMOUSE_WHEEL,      0, TEXT("Change ship type"), },
  319.     { INPUT_FIREWEAPONS,     DIMOUSE_BUTTON0,    0, TEXT("Fire weapons"), },
  320.     { INPUT_CHANGEWEAPONS,   DIMOUSE_BUTTON1,    0, TEXT("Change weapons"), },
  321. };
  322.  
  323. // Game actions used by this game.
  324. DIACTION g_rgBrowserAction[] =
  325. {
  326.     // (C:\Program Files\DirectX\DirectInput\User Maps\*.ini)
  327.     // after changing this, otherwise settings won't reset and will be read 
  328.     // from the out of date ini files 
  329.  
  330.     // Device input (joystick, etc.) that is pre-defined by DInput, according
  331.     // to genre type. The genre for this app is space simulators.
  332.     { INPUT_MENU_UD,         DIAXIS_BROWSER_MOVE,       0, TEXT("Up/down"), },
  333.     { INPUT_MENU_UP,         DIBUTTON_BROWSER_PREVIOUS, 0, TEXT("Up"), },
  334.     { INPUT_MENU_DOWN,       DIBUTTON_BROWSER_NEXT,     0, TEXT("Down"), },
  335.     { INPUT_MENU_SELECT,     DIBUTTON_BROWSER_SELECT,   0, TEXT("Select"), },
  336.     { INPUT_MENU_QUIT,       DIBUTTON_BROWSER_DEVICE,   0, TEXT("Quit menu"), },
  337.  
  338.     // Keyboard input mappings
  339.     { INPUT_MENU_UP,         DIKEYBOARD_UP,          0, TEXT("Up"), },
  340.     { INPUT_MENU_DOWN,       DIKEYBOARD_DOWN,        0, TEXT("Down"), },
  341.     { INPUT_MENU_SELECT,     DIKEYBOARD_SPACE,       0, TEXT("Select"), },
  342.     { INPUT_MENU_SELECT,     DIKEYBOARD_RETURN,      0, TEXT("Select"), },
  343.     { INPUT_MENU_SELECT,     DIKEYBOARD_NUMPADENTER, 0, TEXT("Select"), },
  344.     { INPUT_MENU_QUIT,       DIKEYBOARD_ESCAPE,      0, TEXT("Quit menu"), },
  345.  
  346.     // Mouse input mappings
  347.     { INPUT_MENU_WHEEL,      DIMOUSE_WHEEL,      0, TEXT("Up/down"), },
  348.     { INPUT_MENU_SELECT,     DIMOUSE_BUTTON0,    0, TEXT("Select"), },
  349. };
  350.  
  351. // Number of actions
  352. #define NUMBER_OF_GAMEACTIONS    (sizeof(g_rgGameAction)/sizeof(DIACTION))
  353. #define NUMBER_OF_BROWSERACTIONS (sizeof(g_rgBrowserAction)/sizeof(DIACTION))
  354.  
  355.  
  356. //-----------------------------------------------------------------------------
  357. // Inline helper functions
  358. //-----------------------------------------------------------------------------
  359.  
  360. // Simple function to define "hilliness" for terrain
  361. inline FLOAT HeightField( FLOAT x, FLOAT z )
  362. {
  363.     return (cosf(x/2.0f+0.2f)*cosf(z/1.5f-0.2f)+1.0f) - 2.0f;
  364. }
  365.  
  366. // Simple function for generating random numbers
  367. inline FLOAT rnd( FLOAT low, FLOAT high )
  368. {
  369.     return low + ( high - low ) * ( (FLOAT)rand() ) / RAND_MAX;
  370. }
  371.  
  372. FLOAT rnd( FLOAT low=-1.0f, FLOAT high=1.0f );
  373.  
  374. // Convenient macros for playing sounds
  375. inline VOID PlaySound( CMusicSegment* pSound )
  376. {
  377.         if( pSound ) pSound->Play( DMUS_SEGF_SECONDARY );
  378. }
  379.  
  380. inline VOID StopSound( CMusicSegment* pSound )
  381. {
  382.         if( pSound ) pSound->Stop();
  383. }
  384.  
  385.  
  386. //-----------------------------------------------------------------------------
  387. // Function prototypes
  388. //-----------------------------------------------------------------------------
  389. LRESULT CALLBACK StaticMsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
  390.  
  391.  
  392.  
  393. //-----------------------------------------------------------------------------
  394. // Name: class CMyApplication 
  395. // Desc: Application class.
  396. //-----------------------------------------------------------------------------
  397. class CMyApplication 
  398. {
  399. public:
  400.     HRESULT Create( HINSTANCE hInstance );
  401.     INT     Run();
  402.     LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  403.  
  404.     CMyApplication();
  405.  
  406.     HRESULT InputAddDeviceCB( CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi );
  407.     static HRESULT CALLBACK StaticInputAddDeviceCB( CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID pParam );   
  408.     BOOL    ConfigureInputDevicesCB( IUnknown* pUnknown );
  409.     static BOOL CALLBACK StaticConfigureInputDevicesCB( IUnknown* pUnknown, VOID* pUserData );
  410.  
  411. protected:
  412.     HRESULT          OneTimeSceneInit( HWND hWnd );
  413.     HRESULT          FrameMove();
  414.     HRESULT          RenderFrame();
  415.     VOID             FinalCleanup();
  416.  
  417.     // Sound functions
  418.     HRESULT          CreateSoundObjects( HWND hWnd );
  419.     VOID             DestroySoundObjects();
  420.  
  421.     // Input functions
  422.     HRESULT          CreateInputObjects( HWND hWnd );
  423.     VOID             DestroyInputObjects();
  424.     void             UpdateInput( UserInput* pUserInput );
  425.  
  426.     // Display functions
  427.     HRESULT          CreateDisplayObjects( HWND hWnd );
  428.     HRESULT          RestoreDisplayObjects();
  429.     HRESULT          InvalidateDisplayObjects();
  430.     HRESULT          DestroyDisplayObjects();
  431.     HRESULT          SwitchDisplayModes( BOOL bFullScreen, DWORD dwWidth, DWORD dwHeight );
  432.  
  433.     // Menu functions
  434.     VOID             ConstructMenus();
  435.     VOID             DestroyMenus();
  436.     VOID             UpdateMenus();
  437.  
  438.     // Rendering functions
  439.     VOID             UpdateDisplayList();
  440.     VOID             DrawDisplayList();
  441.     VOID             ShowFrame();
  442.     VOID             DarkenScene( FLOAT fAmount );
  443.     VOID             RenderFieryText( CD3DFont* pFont, TCHAR* strText );
  444.  
  445.     // Misc game functions
  446.     VOID             DisplayLevelIntroScreen( DWORD dwLevel );
  447.     VOID             AdvanceLevel();
  448.     BOOL             IsDisplayListEmpty();
  449.     VOID             AddToList( DisplayObject* pObject );
  450.     VOID             DeleteFromList( DisplayObject* pObject );
  451.     VOID             CheckForHits();
  452.  
  453.     HRESULT          LoadTerrainModel();
  454.     HRESULT          LoadShipModel();
  455.     HRESULT          SwitchModel();
  456.  
  457.     // Error handling
  458.     VOID             CleanupAndDisplayError( DWORD dwError );
  459.  
  460. protected:
  461.     TCHAR*               m_strAppName;
  462.     HWND                 m_hWndMain;                // Main window
  463.     DWORD                m_dwScreenWidth;           // Dimensions for fullscreen modes
  464.     DWORD                m_dwScreenHeight;
  465.     D3DDISPLAYMODE       m_DesktopMode;
  466.     D3DFORMAT            m_d3dfmtFullscreen;        // Pixel format for fullscreen modes
  467.     D3DFORMAT            m_d3dfmtTexture;           // Pixel format for textures
  468.     BOOL                 m_bFullScreen;             // Whether app is fullscreen (or windowed)
  469.     BOOL                 m_bIsActive;               // Whether app is active
  470.     BOOL                 m_bDisplayReady;           // Whether display class is initialized
  471.     BOOL                 m_bMouseVisible;           // Whether mouse is visible
  472.     HBITMAP              m_hSplashBitmap;           // Bitmap for splash screen
  473.  
  474.     DWORD                m_dwAppState;              // Current state the app is in
  475.     DWORD                m_dwLevel;                 // Current game level
  476.     DWORD                m_dwScore;                 // Current game score
  477.  
  478.     // Player view mode
  479.     #define NUMVIEWMODES 3
  480.     CD3DCamera           m_Camera;                  // Camera used for 3D scene
  481.     DWORD                m_dwViewMode;              // Which view mode is being used
  482.     FLOAT                m_fViewTransition;         // Amount used to transittion views
  483.     BOOL                 m_bAnimatingViewChange;    // Whether view is transitioning
  484.     BOOL                 m_bFirstPersonView;        // Whether view is first-person
  485.  
  486.     // Bullet mode
  487.     FLOAT                m_fBulletRechargeTime;     // Recharge time for firing bullets
  488.     DWORD                m_dwBulletType;            // Current bullet type
  489.  
  490.     // Display list and player ship
  491.     DisplayObject*       m_pDisplayList;            // Global display list
  492.     CShip*               m_pShip;                   // Player's display object
  493.  
  494.     // DirectDraw/Direct3D objects
  495.     LPDIRECT3DDEVICE8       m_pd3dDevice;           // Class to handle D3D device
  496.     D3DPRESENT_PARAMETERS   m_d3dpp;
  497.     LPDIRECT3DSURFACE8      m_pConfigSurface;       // Surface for config'ing DInput devices
  498.     LPDIRECT3DVERTEXBUFFER8 m_pViewportVB;
  499.     LPDIRECT3DVERTEXBUFFER8 m_pSpriteVB;
  500.  
  501.     // Support for the ship model
  502.     CD3DMesh*            m_pShipFileObject;         // Geometry model of player's ship
  503.     DWORD                m_dwNumShipTypes;
  504.     DWORD                m_dwCurrentShipType;
  505.  
  506.     // DirectMusic objects
  507.     CMusicManager*       m_pMusicManager;           // Class to manage DMusic objects
  508.     CMusicSegment*       m_pBeginLevelSound;        // Sounds for the app
  509.     CMusicSegment*       m_pEngineIdleSound;
  510.     CMusicSegment*       m_pEngineRevSound;
  511.     CMusicSegment*       m_pShieldBuzzSound;
  512.     CMusicSegment*       m_pShipExplodeSound;
  513.     CMusicSegment*       m_pFireBulletSound;
  514.     CMusicSegment*       m_pShipBounceSound;
  515.     CMusicSegment*       m_pDonutExplodeSound;
  516.     CMusicSegment*       m_pPyramidExplodeSound;
  517.     CMusicSegment*       m_pCubeExplodeSound;
  518.     CMusicSegment*       m_pSphereExplodeSound;
  519.  
  520.     // Game objects
  521.     LPDIRECT3DTEXTURE8   m_pGameTexture1;           // Texture with game object animations
  522.     LPDIRECT3DTEXTURE8   m_pGameTexture2;           // Texture with game object animations
  523.     CD3DMesh*            m_pTerrain;                // Geometry model of terrain
  524.     CD3DFont*            m_pGameFont;               // Font for displaying score, etc.
  525.     CD3DFont*            m_pMenuFont;               // Font for displaying in-game menus
  526.  
  527.  
  528.     // Menu objects
  529.     CMenuItem*           m_pMainMenu;               // Menu class for in-game menus
  530.     CMenuItem*           m_pQuitMenu;
  531.     CMenuItem*           m_pCurrentMenu;
  532.  
  533.     // DirectInput objects
  534.     CInputDeviceManager* m_pInputDeviceManager;     // Class for managing DInput devices
  535.     UserInput            m_UserInput;               // Struct for storing user input 
  536.     DIACTIONFORMAT       m_diafGame;                // Action format for game play
  537.     DIACTIONFORMAT       m_diafBrowser;             // Action format for menu navigation
  538.  
  539.     BOOL                 m_bPaused;    
  540. };
  541.  
  542.  
  543. #endif
  544.  
  545.